]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Override activate() for wireless
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 3 Aug 2022 21:24:53 +0000 (23:24 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 10 Aug 2022 16:37:15 +0000 (16:37 +0000)
Wireless items represent a single adapter, but wireless connectivity
is controlled globally under NetworkManager.

So instead of delegating activation to items, bind the :checked
property to the global :wireless-enabled property and toggle it
on activate.

As any wireless devices will change their state to UNAVAILABLE
when wireless is disabled, don't remove corresponding items in
that case to keep the section visible.

We don't want to hide the button to turn Wi-Fi back on when toggled
off :-)

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>

js/ui/status/network.js

index 431ca5ad68a89add09d19aac6aa08443acc225f5..28a5cfa0f932eba8800ff9615b0d6c22c25a6ce3 100644 (file)
@@ -1699,9 +1699,32 @@ class NMWirelessSection extends NMDeviceSection {
             'gnome-wifi-panel.desktop');
     }
 
+    setClient(client) {
+        super.setClient(client);
+
+        this._client?.bind_property('wireless-enabled',
+            this, 'checked',
+            GObject.BindingFlags.SYNC_CREATE);
+    }
+
+    activate() {
+        this._client.wireless_enabled = !this._client.wireless_enabled;
+    }
+
     _createDeviceMenuItem(device) {
         return new NMWirelessDeviceItem(this._client, device);
     }
+
+    _updateChecked() {
+        // handled via a property binding
+    }
+
+    _shouldShowDevice(device) {
+        // don't disappear if wireless-enabled is false
+        if (device.state === NM.DeviceState.UNAVAILABLE)
+            return true;
+        return super._shouldShowDevice(device);
+    }
 });
 
 const NMWiredSection = GObject.registerClass(